package com.hyt.it.ogt.kq.common.gov.enums;

import cn.hutool.core.util.BooleanUtil;
import lombok.Getter;

import java.util.Arrays;

/**
 * 生成状态
 * 0-未生成，
 * 1-已生成
 */
@Getter
public enum GenerateStatusEnum {

	YES(1, "已生成"),
    NO(0, "未生成"),
    ;

    private Integer type;
    private String desc;

    GenerateStatusEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static String[] allDesc() {
        return Arrays.stream(values())
                .map(GenerateStatusEnum::getDesc)
                .toArray(String[]::new);
    }

    public static String getTypeByDesc(String desc) {
        for (GenerateStatusEnum identityTypeEnum : values()) {
            if (identityTypeEnum.getDesc().equals(desc)) {
                return identityTypeEnum.getType().toString();
            }
        }
        return null;
    }

    public static String getDescByType(Boolean type) {
        Integer typeInt = BooleanUtil.toInteger(type);
        for (GenerateStatusEnum identityTypeEnum : values()) {
            if (identityTypeEnum.getType().equals(typeInt)) {
                return identityTypeEnum.getDesc();
            }
        }
        return null;
    }
}
